const express = require('express');
const { authMiddleware } = require('../../middlewares/authMiddleware');
const { apiPathMiddleware } = require('../../middlewares/apiPathMiddleware');
const spuController = require('../../controllers/product/spuController');

const router = express.Router();

// router.get('/get', authMiddleware, spuController.get);
// router.post('/create', authMiddleware, spuController.create);
// router.put('/update', authMiddleware, spuController.update);
// router.delete('/delete', authMiddleware, spuController.delete);
// 获取某个SPU的图片列表
router.get('/spuImageList/:spuId', spuController.getSpuImageList)
// 获取某个SPU下的销售属性列表
router.get('/spuSaleAttrList/:spuId', spuController.getSpuSaleAttrList)
// 获取整个项目全部的销售属性
router.get('/baseSaleAttrList', spuController.getBaseSaleAttrList);
// 新增spu
router.post('/saveSpuInfo', authMiddleware, apiPathMiddleware('spu/save'), spuController.saveSpuInfo);
// 更新spu
router.put('/updateSpuInfo', authMiddleware, apiPathMiddleware('spu/update'), spuController.updateSpuInfo);
// 删除spu
router.delete('/deleteSpu/:spuId', authMiddleware, apiPathMiddleware('spu/remove'), spuController.deleteSpu);
// 给某个spu添加一个sku
router.post('/saveSkuInfo', authMiddleware, apiPathMiddleware('spu/saveSku'), spuController.saveSkuInfo);
// 查看某个spu下的sku列表
router.get('/findBySpuId/:spuId', spuController.getSkuList);
// 获取某一个分类下的spu列表
router.get('/:page/:limit', spuController.getSpuList);

module.exports = router;